package main

import "fmt"

func calc(str string) (charCount int,numCount int,spaceCount int,otherCount int){
/*
// rune is an alias for int32 and is equivalent to int32 in all ways. It is
// used, by convention, to distinguish character values from integer values.
type rune = int32
*/
 utfChars := []rune(str)
  for i := 0; i < len(utfChars); i++ {
    if utfChars[i]>='a'&&utfChars[i]<= 'z' || utfChars[i]>='A'&&utfChars[i]<= 'Z'{
      charCount++
      continue
    }

    if utfChars[i]>='0'&&utfChars[i]<= '9' {
      numCount++
      continue
    }

    if utfChars[i]==' '{
      spaceCount++
      continue
    }

    otherCount++
  }
  return
}

func example1(){
  var str string = "dfka    我爱天安门 哈哈哈哈2333"
  charCount, numCount, spCount, otherCount := calc(str)
  fmt.Printf("charCount:%d numCount:%d spCount:%d otherCount:%d\n",charCount,numCount,spCount,otherCount)
}

func main() {
  example1()
}

